<div class="records margintop20">
    <table class="table">
        <thead>
            <tr class="trcolor">
                <th style="width: 10%">标题</th>
                <th style="width: 8%">发送人</th>
                <th style="width: 6%">时间</th>
                <th style="width: 6%">详情</th>
            </tr>
        </thead>
        <tbody id="noticelist-tbody">
        </tbody>
    </table>

    <div class="page_info">
        <div id="listPage" class="megas512 zxf_pagediv"></div>    
    </div>
</div>

<script>
    Util.queryTemplate($("#noticelist-tbody"), ".zxf_pagediv", null, function(page, size, cb) {
        CMD.notice_uquery(undefined, undefined, size, page, cb);
    }, function(table, list) {
        if (Util.isEmpty(list)) {
            table.append("<tr><td colspan='4'>暂无数据</td></tr>");
            return;
        }
        for (var i in list) {
            var d = Message.convert(list[i]);
            if (i % 2 == 0) var tr = $("<tr class='trcolor'></tr>");
            else var tr = $("<tr></tr>");
            tr.append("<td>" + d.subject + "</td>");
            tr.append("<td>系统管理员</td>");
            tr.append("<td>" + d.time + "</td>");
            var l = '<td><a href="#" value="__v__">详情<i class="new_user_notice_msg __c__" title="您有新的消息" style="margin: -6px 12px 0 5px;"></i></a></td>';
            if (d.read || d.forever) l = l.replace(/__c__/, "hide");
            else l = l.replace(/__c__/, "");
            l = l.replace(/__v__/, d.id);
            tr.append(l);            
            table.append(tr);
        }

        table.find("a").click(function(e) {
            var id = $(e.currentTarget).attr("value");
            var d = null
            for (var i in list) {
                if (list[i].id == id) {
                    d = list[i];
                    layer.open({
                        type : 1,
                        title : '消息详情',
                        scrollbar : false,
                        shade : [ 0.5 ],
                        area : [ '500px', '400px' ],
                        content : '<div class="pop-detail">' + d.content + '</div>'
                    });
                    $("#layui-layer-content").css("height", "368px");
                    break;
                }
            }
            $(e.currentTarget).find("i").hide();
            if (!d.forever)
                CMD.notice_flag_read(id);
        });
    });
</script>